package org.liuhy
{
	import flash.geom.Point;
	
	import mx.core.UIComponent;
	
	import org.liuhy.line.AbstractLine;
	import org.liuhy.line.CLine;
	import org.liuhy.line.rect.RectLine;
	import org.liuhy.node.CircleFlowNode;
	import org.liuhy.node.DiamondFlowNode;
	import org.liuhy.node.FlowNode;
	import org.liuhy.node.RectFlowNode;
	import org.liuhy.node.StartFlowNode;
	import org.liuhy.node.StopFlowNode;
	
	public class GraphicFactory
	{
		//流程节点工厂;
		public function GraphicFactory()
		{
		}
		public static function getFlowNode(p_type:String,p_x:int,p_y:int,p_width:int,p_height:int):FlowNode{
			if("rect"==p_type){
				return  new RectFlowNode(p_x,p_y,p_width,p_height);				
			}else if("diamond"==p_type){
				return  new DiamondFlowNode(p_x,p_y,p_width,p_height);
			}else if("circle"==p_type){
				return  new CircleFlowNode(p_x,p_y,p_width,p_height);			
			}else if("start"==p_type){
				return new StartFlowNode(p_x,p_y,p_width,p_height);				
			}else if("stop"==p_type){
				return new StopFlowNode(p_x,p_y,p_width,p_height);				
			}
			return null;
		}
		public static function createNEW(p_type:String,p_point:Point):UIComponent{
			if("line"==p_type){
				var _cLine:CLine = new CLine();
				var _line:AbstractLine = new RectLine(p_point.x,p_point.y,p_point.x+200,p_point.y,_cLine);
				_line.draw();
				return _cLine;
			}else if("rect"==p_type){
				var _rect:FlowNode 	= new RectFlowNode(p_point.x,p_point.y,100,75);
				_rect.draw();
				return _rect;
			}else if("diamond"==p_type){
				var _rect:FlowNode 	= new DiamondFlowNode(p_point.x,p_point.y,100,75);
				_rect.draw();
				return _rect;
			}else if("circle"==p_type){
				var _rect:FlowNode 	= new CircleFlowNode(p_point.x,p_point.y,100,75);
				_rect.draw();
				return _rect;
			}else if("start"==p_type){
				var _rect:FlowNode 	= new StartFlowNode(p_point.x,p_point.y,50,50);
				_rect.draw();
				return _rect;
			}else if("stop"==p_type){
				var _rect:FlowNode 	= new StopFlowNode(p_point.x,p_point.y,50,50);
				_rect.draw();
				return _rect;
			}
			return null;
		}
	}
}